Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blocks): Add support for mutually exclusive input fields #8856

Merged

Conversation

Abhi1992002
Copy link
Contributor

@Abhi1992002 Abhi1992002 commented Dec 2, 2024

Changes

  • Introduced mutually_exclusive parameter in SchemaField to manage input exclusivity.
  • Implemented logic in NodeGenericInputField to disable inputs based on mutual exclusivity.
  • Updated related components to support the new disabled state for inputs.
  • Enhanced BlockIOSubSchemaMeta to include mutually_exclusive property.

Currently, I’m disabling the input from the same group (I haven’t added any frontend validation to prevent users from bypassing it).

Screen.Recording.2024-12-02.at.5.08.42.PM.mov

@Abhi1992002 Abhi1992002 requested a review from a team as a code owner December 2, 2024 11:46
@Abhi1992002 Abhi1992002 requested review from Torantulino and majdyz and removed request for a team December 2, 2024 11:46
Copy link

netlify bot commented Dec 2, 2024

Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
🔨 Latest commit d23764b
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/6760b4e67259de0008f7a9cc

@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end platform/blocks size/l labels Dec 2, 2024
@Abhi1992002 Abhi1992002 changed the title Feat/single input validation lock feat(platform) : single input validation lock Dec 2, 2024
Copy link

netlify bot commented Dec 2, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit d23764b
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6760b4e7ec227a0008538c90

@Abhi1992002 Abhi1992002 marked this pull request as draft December 2, 2024 11:51
@Abhi1992002 Abhi1992002 marked this pull request as ready for review December 2, 2024 12:58
Copy link
Member

@Pwuts Pwuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good feature, but I'm not sure about the implementation. JSON schema has oneOf keyword which seems perfect for this purpose. What do you think?

I always prefer using an existing mechanism or standard rather than inventing our own, unless that makes implementation unreasonably complex.

@Pwuts Pwuts changed the title feat(platform) : single input validation lock feat(blocks): Add support for mutually exclusive input fields Dec 5, 2024
@majdyz majdyz removed their request for review December 10, 2024 22:43
@ntindle
Copy link
Member

ntindle commented Dec 12, 2024

This is a good feature, but I'm not sure about the implementation. JSON schema has oneOf keyword which seems perfect for this purpose. What do you think?

I always prefer using an existing mechanism or standard rather than inventing our own, unless that makes implementation unreasonably complex.

How would that look? I figure if we did that we'd need to implement the rest: allOf, anyOf, oneOf, not, if, then, etc

See also #8852

Imo this isn't worth blocking over and json schema is far more complex than meets the eye

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Dec 13, 2024
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

### Changes
- Introduced `mutually_exclusive` parameter in `SchemaField` to manage input exclusivity.
- Implemented logic in `NodeGenericInputField` to disable inputs based on mutual exclusivity.
- Updated related components to support the new `disabled` state for inputs.
- Enhanced `BlockIOSubSchemaMeta` to include `mutually_exclusive` property.

# Conflicts:
#	autogpt_platform/frontend/src/components/node-input-components.tsx
…fields

### Changes
- Added `mutually_exclusive` parameter to `SchemaField` for `text_input_1`, `text_input_2`, and `text_input_3` to group them under "group_1".
- Updated `number_input_1` and `number_input_2` to belong to "group2" for mutual exclusivity.
@Abhi1992002 Abhi1992002 force-pushed the feat/single-input-validation-lock branch from 0484484 to 405f630 Compare December 16, 2024 16:31
@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Dec 16, 2024
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@Abhi1992002
Copy link
Contributor Author

@Pwuts and @ntindle I have changed the implementation from mutually exclusive to oneOf. Now you can check it.

Demo

Screen.Recording.2024-12-16.at.9.58.53.PM.mov

ntindle
ntindle previously approved these changes Dec 16, 2024
@ntindle ntindle enabled auto-merge December 16, 2024 23:25
@ntindle ntindle added this pull request to the merge queue Dec 16, 2024
Merged via the queue into Significant-Gravitas:dev with commit 2fe6eb1 Dec 16, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end size/l
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants